package com.shuoyue.ycgk.ui.papergroups.running.myrush;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.PaperSet;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import java.util.List;

import io.reactivex.Observable;

public interface UserRushContract {
    interface View extends BaseView {

        void setPaperSetInfo(List<RushBean> rushBeans);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();


        public void getRushList() {
            apply(model.getRushList())
                    .subscribe(new ApiSubscriber<Optional<List<RushBean>>>(mView, this) {
                        @Override
                        public void onNext(Optional<List<RushBean>> listOptional) {
                            super.onNext(listOptional);
                            mView.setPaperSetInfo(listOptional.getIncludeNull());
                        }
                    });
        }


    }

    class Model extends BaseModel {

        Observable<BaseResult<List<RushBean>>> getRushList() {
            return RetrofitClient.getInstance().getApi().getRushList();
        }

    }
}
